﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SelfRotateControl : MonoBehaviour
{
    public RotateBall rb;
    Text text;
    private void Awake()
    {
        text = GetComponent<Text>();
    }

    private void Start()
    {
        GetComponentInParent<Button>().onClick.Invoke();
    }

    float lastS = 1;
    public void RotateOrNot()
    {
        if (rb.speed!=0)
        {
            lastS = rb.speed;
            rb.speed = 0;
            text.text = "自转";
        }
        else
        {
            rb.speed = lastS;
            text.text = "停止自转";
        }
    }
}
